import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;


// "dasdsawqeqw"  1
//	 *   输出:
//	 *   e
//	 *   "dasdsawqeqw"  2
//	 *   输出:
//	 *   d
//	 *   a
//	 *   s
//	 *   w
//	 *   q

public class Java003 {
    public static int a;
    public static void main(String[] args) {
        HashMap<Character,Integer> map = new HashMap<Character,Integer>();
        Scanner sc = new Scanner(System.in);
        System.out.println("Stirng");
        String s = sc.nextLine();
        System.out.println("Num");
        int NUM = sc.nextInt();

        ArrayList<Character> str = new ArrayList<>();

        for(char c :s.toCharArray()){
            str.add(c);
        }//准备工作

        //lambda表达式
        Map<Character, Long> map1 = str.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
        System.out.println("统计:"+map1);
        System.out.println("正在输出出现: "+NUM+" 次的值");
        map1.entrySet().stream().filter(c->c.getValue()==3).forEach(c->System.out.println(c));

        //引用
        System.out.println("=======");

        str.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting())).entrySet().stream().filter(c->c.getValue()==3).forEach(System.out::println);




    }
}
